package com.taptech.doufu.ui.dialog;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import androidx.annotation.NonNull;
import android.view.View;
import android.widget.TextView;

import com.taptech.doufu.R;

/**
 * Created by Wyatt on 2017/9/18/018.
 */

public class SingleBtnDialog extends Dialog{
    private TextView tvTitle,tvTip,tvBtn;
    private String tip,title;
    private String btnText = "确定";
    private OnBtnClickListener mListener;
    public SingleBtnDialog(@NonNull Context context, int theme, String tip,String title) {
        super(context,theme);
        this.tip = tip;
        this.title = title;
    }

    public SingleBtnDialog(@NonNull Context context, int theme, String tip,String title,String btnText) {
        super(context,theme);
        this.tip = tip;
        this.title = title;
        this.btnText = btnText;
    }

    public void setOnBtnClickListener(OnBtnClickListener listener) {
        mListener = listener;
    }


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_single_btn_1);
        tvTitle = (TextView) findViewById(R.id.tvTitle);
        tvTitle.setText(title);
        tvTip = (TextView) findViewById(R.id.tvTip);
        tvTip.setText(tip);
        tvBtn = (TextView) findViewById(R.id.tvBtn);
        tvBtn.setText(btnText);
        tvBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (mListener != null) {
                    mListener.onClick();
                }
                dismiss();
            }
        });
    }

    public interface OnBtnClickListener{
        void onClick();
    }
}
